layui.config({
	base: '/static/plugin/build/js/'
}).use(['ztree', 'layer', 'form'], function() {
	var $ = layui.$;
	var layer = layui.layer;
	var form = layui.form;
	var setting = {
		view: {
			showLine: true,
			showTitle: true,
			selectedMulti: false
		},
		edit: {
			enable: false
		},
		data: {
			simpleData: {
				enable: true
			}
		},
		callback: {
			onClick: deptTreeClick,
		}
	}
	//加载资源树
	loadDeptTree();
	var editNodeID = "";
	var operFlag = "view";

	function loadDeptTree() {
		$.get(
			"/mock/resourceManagement.json",
			function(result) {
				if(result.status== 0) {
					var zNodes = result.zNodes;
					//加载tree
					$.fn.zTree.init($("#ztree"), setting, zNodes);
					//根节点被选中
					var treeObj = $.fn.zTree.getZTreeObj("ztree");
					var node = treeObj.getNodeByParam("id", "resourcecenter", null);
					treeObj.selectNode(node);
					deptTreeClick(event, "ztree", node);
				}
			},
			"json"
		);
	}

	function deptTreeClick(event, treeId, treeNode) {
		$("#name").val(treeNode.name);
		operFlag = "view";
	}
	
});